<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:template match="/">
Imports System
Imports System.Data
Imports <xsl:value-of select="Schema/@EntityNameSpace" />
Imports <xsl:value-of select="Schema/@DataAccessNameSpace" />

Namespace <xsl:value-of select="Schema/@NameSpace" />
	Public Class <xsl:value-of select="Schema/@TableName" />Biz
		Public <xsl:if test="Schema/@IsStatic='True'">Shared </xsl:if>Sub Add<xsl:value-of select="Schema/@TableName" />(obj<xsl:value-of select="Schema/@TableName" /> As <xsl:value-of select="Schema/@TableName" />)
			Dim obj<xsl:value-of select="Schema/@TableName" />DAL As New <xsl:value-of select="Schema/@TableName" />Insert()
			obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />)
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery()<xsl:for-each select="Schema/Columns[IS_IDENTITY='1']">
			obj<xsl:value-of select="/Schema/@TableName" />.<xsl:value-of select="COLUMN_NAME" /> = obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /></xsl:for-each>
		End Sub

		Public <xsl:if test="Schema/@IsStatic='True'">Shared </xsl:if>Function GetAll<xsl:value-of select="Schema/@TableName" />() As DataTable
			Dim obj<xsl:value-of select="Schema/@TableName" />DAL As New <xsl:value-of select="Schema/@TableName" />SelectAll()
			Return obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable()
		End Function<xsl:if test="Schema/@IfHavePK=1 and Schema/@IfAllPK=0">

		Public <xsl:if test="Schema/@IsStatic='True'">Shared </xsl:if>Sub Update<xsl:value-of select="Schema/@TableName" />(obj<xsl:value-of select="Schema/@TableName" /> As <xsl:value-of select="Schema/@TableName" />)
			Dim obj<xsl:value-of select="Schema/@TableName" />DAL As New <xsl:value-of select="Schema/@TableName" />Update()
			obj<xsl:value-of select="Schema/@TableName" />DAL.ReceiveParameter(obj<xsl:value-of select="Schema/@TableName" />)
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery()
		End Sub</xsl:if><xsl:if test="Schema/@IfHavePK=1">

		Public <xsl:if test="Schema/@IsStatic='True'">Shared </xsl:if>Sub Delete<xsl:value-of select="Schema/@TableName" />(<xsl:for-each select="Schema/Columns[IS_PK='1']">ByVal <xsl:value-of select="concat(COLUMN_NAME,' As ',LANGUAGE_TYPE)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>)
			Dim obj<xsl:value-of select="Schema/@TableName" />DAL As New <xsl:value-of select="Schema/@TableName" />Delete<xsl:for-each select="Schema/Columns[IS_PK='1']">
			obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" /></xsl:for-each>
			obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteNoQuery()
		End Sub

		Public <xsl:if test="Schema/@IsStatic='True'">Shared </xsl:if>Function Get<xsl:value-of select="Schema/@TableName" />(<xsl:for-each select="Schema/Columns[IS_PK='1']">ByVal <xsl:value-of select="concat(COLUMN_NAME,' As ',LANGUAGE_TYPE)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>) As <xsl:value-of select="Schema/@TableName" />
			Dim obj<xsl:value-of select="Schema/@TableName" />DAL As New <xsl:value-of select="Schema/@TableName" />SelectByPk()
			Dim obj<xsl:value-of select="Schema/@TableName" /> As New <xsl:value-of select="Schema/@TableName" />()<xsl:for-each select="Schema/Columns[IS_PK='1']">
			obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="COLUMN_NAME" /> = <xsl:value-of select="COLUMN_NAME" /></xsl:for-each>
			obj<xsl:value-of select="Schema/@TableName" />.MetaDataTable = obj<xsl:value-of select="Schema/@TableName" />DAL.ExecuteDataTable()
			Return obj<xsl:value-of select="Schema/@TableName" />
		End Function</xsl:if>

<xsl:for-each select="Schema/ForeignKeys/ForeignKey">
		Public <xsl:if test="/Schema/@IsStatic='True'">Shared </xsl:if>Function Get<xsl:value-of select="/Schema/@TableName" />By<xsl:for-each select="Column"><xsl:value-of select="FKCOLUMN_NAME" /><xsl:if test="position()!=last()">AND</xsl:if></xsl:for-each>(<xsl:for-each select="Column">ByVal <xsl:value-of select="concat(FKCOLUMN_NAME,' AS ',LANGUAGE_TYPE)" /><xsl:if test="position()!=last()">,</xsl:if></xsl:for-each>) AS DataTable
			Dim obj<xsl:value-of select="/Schema/@TableName" />DAL As New <xsl:value-of select="Schema/@TableName" />SelectBy<xsl:for-each select="Column"><xsl:value-of select="FKCOLUMN_NAME" /><xsl:if test="position()!=last()">AND</xsl:if></xsl:for-each>()<xsl:for-each select="Column">
			obj<xsl:value-of select="/Schema/@TableName" />DAL.<xsl:value-of select="FKCOLUMN_NAME" /> = <xsl:value-of select="FKCOLUMN_NAME" /></xsl:for-each>
			Return obj<xsl:value-of select="/Schema/@TableName" />DAL.ExecuteDataTable()
		End Function
</xsl:for-each>
	End Class
End Namespace</xsl:template>
</xsl:stylesheet>